]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Sort windows when we calculate slots
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 24 Apr 2013 17:53:11 +0000 (13:53 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 24 Apr 2013 18:10:30 +0000 (14:10 -0400)
This ensures that windows don't change positions when we lay
them out again when expanding the workspace switcher.

https://bugzilla.gnome.org/show_bug.cgi?id=698776

js/ui/workspace.js

index ae6ad181a6416456a50157cc1ef2120c75093f1e..ee6dcfcbcc660da426126b2e9a540caa42a782df 100644 (file)
@@ -753,13 +753,6 @@ const LayoutStrategy = new Lang.Class({
         layout.space = space;
     },
 
-    _getDistance: function (row, actor) {
-        let dist_x = actor.x - row.x;
-        let dist_y = actor.y - row.y;
-
-        return Math.sqrt(Math.pow(dist_x, 2) + Math.pow(dist_y, 2));
-    },
-
     computeWindowSlots: function(layout, area) {
         this._computeRowSizes(layout);
 
@@ -788,10 +781,6 @@ const LayoutStrategy = new Lang.Class({
             row.x = area.x + (Math.max(area.width - row.width, 0) / 2) * row.additionalScale;
             row.y = area.y + (y + Math.max(area.height - height, 0) / 2) * row.additionalScale;
             y += row.height + this._rowSpacing;
-
-            row.windows.sort(Lang.bind(this, function(a, b) {
-                return this._getDistance(row, a.realWindow) - this._getDistance(row, b.realWindow);
-            }));
         }
 
         for (let i = 0; i < rows.length; i++) {
@@ -844,6 +833,13 @@ const UnalignedLayoutStrategy = new Lang.Class({
         return false;
     },
 
+    _sortRow: function(row) {
+        // Sort windows horizontally to minimize travel distance
+        row.windows.sort(function(a, b) {
+            return a.realWindow.x - b.realWindow.x;
+        });
+    },
+
     computeLayout: function(windows, layout) {
         let numRows = layout.numRows;
 
@@ -874,6 +870,7 @@ const UnalignedLayoutStrategy = new Lang.Class({
                     row.windows.push(window);
                     row.fullWidth += width;
                 } else {
+                    this._sortRow(row);
                     break;
                 }
             }